home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
TUTORIAL
/
1307B.ZIP
/
ARRAYS2.MOD
< prev
next >
Wrap
Text File
|
1989-01-18
|
2KB
|
69 lines
(* Chapter 6 - Program 2 *)
MODULE Arrays2;
FROM InOut IMPORT WriteString, WriteInt, WriteLn;
VAR Index, Count : CARDINAL;
Checkerboard : ARRAY[1..8] OF ARRAY[1..8] OF CARDINAL;
Value : ARRAY[1..8],[1..8] OF CARDINAL;
BEGIN
FOR Index := 1 TO 8 DO
FOR Count := 1 TO 8 DO
Checkerboard[Index,Count] := Index + 3*Count;
Value[Index,Count] := Index + 2*Checkerboard[Index,Count];
END; (* of Count loop *)
END; (* of Index loop *)
WriteString("Output of checkerboard");
WriteLn;
FOR Index := 1 TO 8 DO
FOR Count := 1 TO 8 DO
WriteInt(Checkerboard[Index,Count],6);
END; (* of Count loop *)
WriteLn;
END; (* of Index loop *)
Value[3,5] := 77; (* change a few of the values *)
Value[3,6] := 3;
Value[Value[3,6],7] := 2; (* same as Value[3,7] := 2; *)
WriteLn;
WriteString("Output of Value matrix");
WriteLn;
FOR Count := 1 TO 8 DO
FOR Index := 1 TO 8 DO
WriteInt(Value[Count,Index],6);
END; (* of Index loop *)
WriteLn;
END; (* of Count loop *)
END Arrays2.
(* Result of execution
Output of checkerboard
4 7 10 13 16 19 22 25
5 8 11 14 17 20 23 26
6 9 12 15 18 21 24 27
7 10 13 16 19 22 25 28
8 11 14 17 20 23 26 29
9 12 15 18 21 24 27 30
10 13 16 19 22 25 28 31
11 14 17 20 23 26 29 32
Output of Value matrix
9 15 21 27 33 39 45 51
12 18 24 30 36 42 48 54
15 21 27 33 77 3 2 57
18 24 30 36 42 48 54 60
21 27 33 39 45 51 57 63
24 30 36 42 48 54 60 66
27 33 39 45 51 57 63 69
30 36 42 48 54 60 66 72
*)